package com.example.api.service.impl;

import com.example.api.mapper.SystemLogMapper;
import com.example.api.model.entity.SystemLog;
import com.example.api.model.vo.SystemLogVo;
import com.example.api.service.SystemLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service
public class SystemLogServiceImpl implements SystemLogService {

    @Resource
    private SystemLogMapper systemLogMapper;

    @Override
    public void record(SystemLog log) {
        // 如果是新记录，设置ID
        if (log.getId() == null || log.getId().isEmpty()) {
            log.setId(UUID.randomUUID().toString());
        }
        systemLogMapper.insert(log);
    }

    @Override
    public List<SystemLog> getAll() {
        return systemLogMapper.findAll();
    }

    @Override
    public void delete(String id) {
        systemLogMapper.deleteById(id);
    }

    @Override
    public List<SystemLog> query(SystemLogVo systemLogVo) {
        return systemLogMapper.queryByConditions(systemLogVo);
    }
}
